package com.school.chapter02.tree_;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

@SuppressWarnings({"all"})
public class BinaryTree_3 {
    private BinaryTree_2 root;

    public BinaryTree_3(){}
    public BinaryTree_3(BinaryTree_2 root){
        this.root = root;
    }
    public void createBiTree(){
        Scanner scn = null;
        try {//- + a # # * # # / e # # f # #
            scn = new Scanner(new File("D:\\projectjavanew\\java-beginner\\DataStructure\\src\\com\\school\\chapter02\\tree_\\input.txt"));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        this.root = createBiTree(root, scn);
    }
    private BinaryTree_2 createBiTree(BinaryTree_2 node, Scanner scn) {
        String temp = scn.next();
        if(temp.trim().equals("#")){
            return null;
        }else{
            node = new BinaryTree_2((String)temp);
            node.setLeft(createBiTree(node.getLeft(), scn));
            node.setRight(createBiTree(node.getRight(), scn));
            return node;
        } }
    public static void main(String[] args){
        BinaryTree_3 bt = new BinaryTree_3();
        bt.createBiTree();
bt.root.preOrder();
//bt.inOrderTraverse();
//bt.postOrderTraverse();
//bt.nrPreOrderTraverse();
//bt.nrInOrderTraverse();
//bt.nrPostOrderTraverse();
//        bt.levelTraverse();
    }
}
